<?php

/*

COMP 353F
Dr. B Desai
Final Project
Group #11

6330746 Nicholas CONSTANTINIDIS
9532862 Jacqueline FU
5484537 Claudio Javier LOPEZ FLORES
9218416 Que Tung NGUYEN

*/

  session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
        <title>CoBAGSys - Home</title>
        <link type="text/css" rel="stylesheet" href="css/mystyle.css">
</head>
<body>
    <?php
      require 'menus.php';
    ?>
    <?php
		function reportPosting() {
			$db = new Connect();
			
			$sql = "INSERT INTO Notice(mID, pID, nDatetime, subject, body) " .
				   "SELECT mID, " . $_GET['pid'] . ", now(), 'Reported posting', 'This posting has been reported, please verify if it conforms to site rules.' " .
				   "FROM MemberInfo " .
				   "WHERE admin = 1" ;
				   
			$result = $db->query($sql);
			
			if(!$result || mysql_affected_rows() == 0) // Couldn't report posting
			{
				return false;
			}
			else // Posting reported
			{
				return true;
			}
		}
		
		$reportsuccess = false;
		if (isset($_GET['pid']))
			$reportsuccess = reportPosting();
    ?>
    <div id="main">
		<p class="title">
			Posting report
		</p>
<?php
	if ($reportsuccess)
	{
		print "<p class=\"normal\">Thank you for reporting this posting! We will take a look at this posting shortly and take appropriate action.</p>";
	}
	else
	{
		print "<p></p><span class=\"error\">INVALID POSTING SPECIFIED!</span>";
	}
?>
    </div>
</body>
</html>
